﻿
@{
    ViewBag.Title = "重置密码";
    Layout = "~/Views/Shared/_LayoutBasal.cshtml";
}

@Scripts.Render("~/Scripts/UserAgent.js")
<script type="text/javascript">
    var _userAgent = new userAgentObj(navigator.userAgent);
    if (_userAgent.device != __device_PC) {
        window.location.href = "/M/Home/Login";
    }
</script>



<script type="text/javascript">

    $(document).ready(function ()
    {
        $("[keyenter]").keypress(function (e)
        {
            if (e.keyCode == 13)
            {
                resetPassword();
            }
        });
    });

    function resetPassword()
    {
        if ($("#formResetPassword").validate({
            rules: {
                    "txtAccount": "required",
                    "txtEmail": "required"
                    },
            messages: {
                    "txtAccount": "!",
                    "txtEmail": "!"
        }
        }).form() == false)
        {
            layerInputAlertMsg();
            return;
        }

        var args = new Object();
        args.Account = $("#txtAccount").val();
        args.Email = $("#txtEmail").val();

        layer.load(0, {
            shade: [0.2, '#fff']
        });

        $.ajax({
            url: "/Api/User/ResetPassword",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR)
            {
                if (data.Success)
                {
                    layer.closeAll();

                    layerAlert("新密码已发送到您的邮箱，请稍候查看您的收件箱（并留意垃圾邮件文件夹）。",
                        function () { window.location.href = "/Home/Login"; });

                } else
                {
                    layer.closeAll();

                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest)
            {
                layer.closeAll();

                //responseText
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

</script>

<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td height="30">&nbsp;</td>
    </tr>
    <tr>
        <td class="font_blue_26">重置密码</td>
    </tr>
    <tr>
        <td height="30">&nbsp;</td>
    </tr>
    <tr>
        <td bgcolor="#62A9F0" height="1"></td>
    </tr>
    <tr>
        <td height="40">&nbsp;</td>
    </tr>
    <tr>
        <td>
            <form id="formResetPassword">
                <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="140" height="50">账户：</td>
                        <td><input name="txtAccount" type="text" class="input_18" style="width:350px;" id="txtAccount" keyenter /></td>
                    </tr>
                    <tr>
                        <td height="30">&nbsp;</td>
                        <td valign="top">
                            <span class="font_gray_15" style="">请输入您的注册账户</span>。
                        </td>
                    </tr>
                    <tr>
                        <td height="50">电子邮件：</td>
                        <td><input name="txtEmail" type="text" class="input_18" style="width:350px;" id="txtEmail" keyenter /></td>
                    </tr>
                    <tr>
                        <td height="30">&nbsp;</td>
                        <td valign="top">
                            <span class="font_gray_15" style="">请输入您注册账户时填写的电子邮件地址。</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="50">&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>

            <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td>重置密码功能将为您生成一个新的随机密码，并发送到您的电子邮箱。</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
            <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
            <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                    <input name="btnResetPassword" type="button" class="btn_blue" id="btnResetPassword" value="重 置" onclick="resetPassword()" />
                        <input name="btnCancel" type="button" class="btn_blue" id="btnCancel" value="取消" onclick="goUrl('@Url.Action("Login")')" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
</table>
